namespace Asmex.FileViewer
{
    using Asmex.ObjViewer;
    using System;
    using System.IO;

    public class ExportDirTable : Region
    {
        private uint _AddressTableEntries;
        private uint _ExportAddressTableRVA;
        private uint _ExportFlags;
        private ushort _MajorVersion;
        private ushort _MinorVersion;
        private string _Name;
        private uint _NamePointerCount;
        private uint _NamePointerRVA;
        private uint _OrdinalBase;
        private uint _OrdinalRVA;
        private uint _TimeStamp;

        public ExportDirTable(BinaryReader reader, MModule mod)
        {
            this._ExportFlags = reader.ReadUInt32();
            this._TimeStamp = reader.ReadUInt32();
            this._MajorVersion = reader.ReadUInt16();
            this._MinorVersion = reader.ReadUInt16();
            this._Name = mod.StringFromRVA(reader, reader.ReadUInt32());
            this._OrdinalBase = reader.ReadUInt32();
            this._AddressTableEntries = reader.ReadUInt32();
            this._NamePointerCount = reader.ReadUInt32();
            this._ExportAddressTableRVA = reader.ReadUInt32();
            this._NamePointerRVA = reader.ReadUInt32();
            this._OrdinalRVA = reader.ReadUInt32();
        }

        public uint AddressTableEntries
        {
            get
            {
                return this._AddressTableEntries;
            }
        }

        [ObjViewer(Hex=true)]
        public uint ExportAddressTableRVA
        {
            get
            {
                return this._ExportAddressTableRVA;
            }
        }

        public uint ExportFlags
        {
            get
            {
                return this._ExportFlags;
            }
        }

        public ushort MajorVersion
        {
            get
            {
                return this._MajorVersion;
            }
        }

        public ushort MinorVersion
        {
            get
            {
                return this._MinorVersion;
            }
        }

        public string Name
        {
            get
            {
                return this._Name;
            }
        }

        public uint NamePointerCount
        {
            get
            {
                return this._NamePointerCount;
            }
        }

        [ObjViewer(Hex=true)]
        public uint NamePointerRVA
        {
            get
            {
                return this._NamePointerRVA;
            }
        }

        public uint OrdinalBase
        {
            get
            {
                return this._OrdinalBase;
            }
        }

        [ObjViewer(Hex=true)]
        public uint OrdinalRVA
        {
            get
            {
                return this._OrdinalRVA;
            }
        }

        public uint TimeStamp
        {
            get
            {
                return this._TimeStamp;
            }
        }
    }
}
